package com.my.mall.client.alehouse.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.my.mall.client.alehouse.service.AlehouseClientService;
import com.my.mall.client.alehouse.vo.AlehouseClientVo;
import com.my.mall.common.Base;

@Controller
@RequestMapping("client/alehouse")
public class AlehouseClientController extends Base {

	@Autowired
	AlehouseClientService alehouseClientService;

	/**
	 * 查询商品
	 * @param categoryId
	 * @param pageNumber
	 * @param length
	 * @return
	 */
	@RequestMapping("selectAlehouseInfoList/{categoryId}/{pageNumber}/{length}")
	@ResponseBody
	public Map<String, Object> selectAlehouseInfoList(@PathVariable("categoryId") int categoryId, @PathVariable("pageNumber") int pageNumber, @PathVariable("length") int length) {
		List<AlehouseClientVo> list = alehouseClientService.selectAlehouseInfoList(categoryId, pageNumber, length);
		int size = alehouseClientService.selectAlehouseInfoCount(categoryId);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("totalRecords", size);
		map.put("list", list);
		return map;
	}

}